%%%---------------------------------------------------------------------------------------
%%% @author    Stuart Jackson <sjackson@simpleenigma.com> [http://erlsoft.org]
%%% @copyright 2006 - 2008 Simple Enigma, Inc. All Rights Reserved.
%%% @doc       AWS User Interface
%%% @reference See <a href="http://erlsoft.org/modules/eifaws" target="_top">Erlang Software Framework</a> for more information
%%% @reference See <a href="http://eifaws.googlecode.com" target="_top">ErlMail Google Code Repository</a> for more information
%%% @version   0.0.1
%%% @since     0.0.1
%%% @end
%%%
%%%
%%% The MIT License
%%%
%%% Copyright (c) 2008 Stuart Jackson, Simple Enigma, Inc. All Righs Reserved
%%%
%%% Permission is hereby granted, free of charge, to any person obtaining a copy
%%% of this software and associated documentation files (the "Software"), to deal
%%% in the Software without restriction, including without limitation the rights
%%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
%%% copies of the Software, and to permit persons to whom the Software is
%%% furnished to do so, subject to the following conditions:
%%%
%%% The above copyright notice and this permission notice shall be included in
%%% all copies or substantial portions of the Software.
%%%
%%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
%%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
%%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
%%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
%%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
%%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
%%% THE SOFTWARE.
%%%
%%%
%%%---------------------------------------------------------------------------------------

-module(eifaws_ui).
-author('sjackson@simpleenigma.com').
-include("../include/eifaws.hrl").
-compile(export_all).

%----------------------------------------
% start() => ok | already_started
%----------------------------------------
start() ->
    case whereis(eifaws_ui) of
	undefined ->
	    Self = self(),
	    spawn(fun() -> init(Self)  end);

	_Pid ->
	    already_started
    end.



init(_Pid) ->
	S = gs:start(),
	W = gs:create(window,S,[{width,300},{height,300}]),
	B1 = gs:create(button,W,[{label, {text,"Button1"}},{y,0}]),
	B2 = gs:create(button,W,[{label, {text,"Button2"}},{y,40}]),
	gs:config(W, {map,true}),
	loop(B1,B2).


loop(B1,B2) ->
	receive
		{gs,B1,click,_Data,_Arg} -> % button 1 pressed
			io:format("Button 1 pressed!~n",[]),
			loop(B1,B2);
		{gs,B2,click,_Data,_Arg} -> % button 2 pressed
			io:format("Button 2 pressed!~n",[]),
			loop(B1,B2)	
	end.



















